<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/**
<span class='line'>  2</span> * @fileoverview The Before Effects LAYER helper module. This module adds methods
<span class='line'>  3</span> * that aid in working with After EFfects layers.
<span class='line'>  4</span> * @author Collin D. Brooks &lt;collin.brooks@gmail.com>
<span class='line'>  5</span> * @version 0.1.0 dev
<span class='line'>  6</span> */</span><span class="WHIT">
<span class='line'>  7</span> 
<span class='line'>  8</span> </span><span class="COMM">//See if BE is already defined</span><span class="WHIT">
<span class='line'>  9</span> </span><span class="NAME">BE</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">BE</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 10</span> 
<span class='line'> 11</span> </span><span class="COMM">/**
<span class='line'> 12</span>  *Contains layer helper methods that provide more functionality than the
<span class='line'> 13</span>  *original AE API.
<span class='line'> 14</span>  *@namespace
<span class='line'> 15</span>  *@extends BE
<span class='line'> 16</span>  *@see BE
<span class='line'> 17</span>  */</span><span class="WHIT">
<span class='line'> 18</span> </span><span class="NAME">BE.layer</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 19</span> </span><span class="WHIT">    </span><span class="NAME">version</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"0.1.0 dev"</span><span class="WHIT">
<span class='line'> 20</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 21</span> 
<span class='line'> 22</span> </span><span class="COMM">/**
<span class='line'> 23</span>  * Adds a marker with a comment to a specified layer at a specificed time.
<span class='line'> 24</span>  * @param {Layer} l The layer to add the marker to.
<span class='line'> 25</span>  * @param {String} time The time to add the marker
<span class='line'> 26</span>  * @param {String|Int} txt The text to add as the marker's comment value
<span class='line'> 27</span>  * @return {Layer} The layer that was sent. Useful for chainging.
<span class='line'> 28</span>  */</span><span class="WHIT">
<span class='line'> 29</span> </span><span class="NAME">BE.layer.addMarker</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">l</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">time</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">txt</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 30</span> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 31</span> </span><span class="WHIT">	</span><span class="NAME">l.property</span><span class="PUNC">(</span><span class="STRN">"Marker"</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">setValueAtTime</span><span class="PUNC">(</span><span class="NAME">time</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">MarkerValue</span><span class="PUNC">(</span><span class="NAME">txt</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 32</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 33</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 34</span> 
<span class='line'> 35</span> </span><span class="COMM">/**
<span class='line'> 36</span>  * Deletes a marker on a layer at a specified index.
<span class='line'> 37</span>  * @param {Layer} l The layer to delete the marker from
<span class='line'> 38</span>  * @param {Int} index The index of the marker to delete
<span class='line'> 39</span>  * @return {Layer} The layer that was sent. Useful for chainging.
<span class='line'> 40</span>  */</span><span class="WHIT">
<span class='line'> 41</span> </span><span class="NAME">BE.layer.deleteMarker</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">l</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">index</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 42</span> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 43</span> </span><span class="WHIT">	</span><span class="NAME">l.property</span><span class="PUNC">(</span><span class="STRN">"Marker"</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">removeKey</span><span class="PUNC">(</span><span class="NAME">index</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 44</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 46</span> 
<span class='line'> 47</span> </span><span class="COMM">/**
<span class='line'> 48</span>  * Get a marker's index based upon its comment value. Goes through each of
<span class='line'> 49</span>  * the markers on the passed layer and returns its index.
<span class='line'> 50</span>  * @param {Layer} l The layer to delete the marker from
<span class='line'> 51</span>  * @param {String} markerText The text to search for in the comment property
<span class='line'> 52</span>  * of the selected layer's marker's. Only exact matches return an index.
<span class='line'> 53</span>  * @return {Bool|Int} False if 'markerText' does not match any comments
<span class='line'> 54</span>  * within the 'l' layer's markers. The index if a match is found.
<span class='line'> 55</span>  */</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="NAME">BE.layer.findMarkerIndex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">l</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">markerText</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 57</span> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 58</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 59</span> 
<span class='line'> 60</span> </span><span class="WHIT">	</span><span class="COMM">//Loop through the markers</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT">	</span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">l.property</span><span class="PUNC">(</span><span class="STRN">"Marker"</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">numKeys</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">>=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT">	</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="WHIT">		</span><span class="COMM">//Does the current marker's comment equal the marker text?</span><span class="WHIT">
<span class='line'> 64</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">l.property</span><span class="PUNC">(</span><span class="STRN">"Marker"</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">keyValue</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">comment</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">markerText</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 65</span> </span><span class="WHIT">		</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT">			</span><span class="COMM">//Return the marker index</span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 69</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 72</span> 
<span class='line'> 73</span> </span><span class="COMM">/**
<span class='line'> 74</span>  * Grabs the time of a marker based upon an index. The time is returned
<span class='line'> 75</span>  * in the current user time format.
<span class='line'> 76</span>  * @param {Layer} l The layer to search for the marker on.
<span class='line'> 77</span>  * @param {Int} markerIndex The index of the marker whose time is to be
<span class='line'> 78</span>  * returned.
<span class='line'> 79</span>  * @returns {String} The time of the marker found at the given index in the
<span class='line'> 80</span>  * current user time format.
<span class='line'> 81</span>  */</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="NAME">BE.layer.getMarkerTime</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">l</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">markerIndex</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 83</span> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT">	</span><span class="NAME">BE.log.debug</span><span class="PUNC">(</span><span class="STRN">"Layer: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">l.name</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"; Marker Index: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">markerIndex</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="WHIT">	</span><span class="NAME">BE.log.debug</span><span class="PUNC">(</span><span class="STRN">"Actual time: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">l.property</span><span class="PUNC">(</span><span class="STRN">"Marker"</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">keyTime</span><span class="PUNC">(</span><span class="NAME">markerIndex</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="WHIT">	</span><span class="NAME">BE.log.debug</span><span class="PUNC">(</span><span class="STRN">"getMarkerTime returns "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">timeToCurrentFormat</span><span class="PUNC">(</span><span class="NAME">l.property</span><span class="PUNC">(</span><span class="STRN">"Marker"</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">keyTime</span><span class="PUNC">(</span><span class="NAME">markerIndex</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="WHIT">				</span><span class="NAME">l.containingComp.frameRate</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT">				</span><span class="KEYW">true</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="WHIT">				</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 90</span> 
<span class='line'> 91</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">timeToCurrentFormat</span><span class="PUNC">(</span><span class="NAME">l.property</span><span class="PUNC">(</span><span class="STRN">"Marker"</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">keyTime</span><span class="PUNC">(</span><span class="NAME">markerIndex</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT">			</span><span class="NAME">l.containingComp.frameRate</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 93</span> </span><span class="WHIT">			</span><span class="KEYW">true</span><span class="WHIT">
<span class='line'> 94</span> </span><span class="WHIT">			</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 95</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 96</span> 
<span class='line'> 97</span> </span><span class="COMM">/**
<span class='line'> 98</span>  *Returns the given layer's inPoint time value based upon the current
<span class='line'> 99</span>  *time format within the project.
<span class='line'>100</span>  *@param {LayerItem} l The layer to get the inPoint time from.
<span class='line'>101</span>  *@returns
<span class='line'>102</span>  */</span><span class="WHIT">
<span class='line'>103</span> </span><span class="NAME">BE.layer.getLayerInPoint</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">l</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>104</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">timeToCurrentFormat</span><span class="PUNC">(</span><span class="NAME">l.inPoint</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">l.containingComp.frameRate</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>105</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>106</span> 
<span class='line'>107</span> </span><span class="COMM">/**
<span class='line'>108</span>  *Returns the given layer's outPoint time value based upon the current
<span class='line'>109</span>  *time format within the project.
<span class='line'>110</span>  *@param {LayerItem} l The layer to get the outPoint time from.
<span class='line'>111</span>  *@returns
<span class='line'>112</span>  */</span><span class="WHIT">
<span class='line'>113</span> </span><span class="NAME">BE.layer.getLayerOutPoint</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">l</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>114</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">timeToCurrentFormat</span><span class="PUNC">(</span><span class="NAME">l.outPoint</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">l.containingComp.frameRate</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>115</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>116</span> </span></pre></body></html>